import 'dart:convert' as convert;
import 'package:http/http.dart' as http;

var baseUrl = 'http://121.37.195.155:3000';

void main(List<String> arguments) async {
  var url = 'http://121.37.195.155:3000/banner';

  // Await the http get response, then decode the json-formatted response.
  var response = await http.get(url);
  if (response.statusCode == 200) {
    var jsonResponse = convert.jsonDecode(response.body);
    // var itemCount = jsonResponse['totalItems'];
    print('Number of books about http: $jsonResponse.');
  } else {
    print('Request failed with status: ${response.statusCode}.');
  }
}

getBanners() async {
  var url = '$baseUrl/banner';
  var response = await http.get(url);

  if (response.statusCode == 200) {
    var jsonResponse = convert.jsonDecode(response.body);
    return jsonResponse;
    // print('Number of books about http: $jsonResponse.');
  } else {
    print('Request failed with status: ${response.statusCode}.');
    throw 'err';
  }
}
